# Maintainer: Alexey Pavlov <Alexpux@gmail.com>

pkgbase=neon
pkgname=("lib${pkgbase}" "lib${pkgbase}-devel")
pkgver=0.30.2
pkgrel=2
pkgdesc="HTTP and WebDAV client library with a C interface"
arch=('i686' 'x86_64')
url="http://www.webdav.org/neon/"
license=('GPL' 'LGPL')
depends=('libexpat' 'openssl' 'ca-certificates')
makedepends=('libexpat-devel' 'openssl-devel')
options=('libtool') # FS#16067
source=(http://www.webdav.org/${pkgbase}/${pkgbase}-${pkgver}.tar.gz{,.asc}
        neon-0.30.2-msys2.patch)
sha256sums=('db0bd8cdec329b48f53a6f00199c92d5ba40b0f015b153718d1b15d3d967fbca'
            'SKIP'
            'ddf8bc1f4f3f9873c6b1d0bf66f6db23eb42da9125d700ee2e065ca59bafff69')

prepare() {
  cd "${srcdir}"/${pkgbase}-${pkgver}

  patch -p1 -i ${srcdir}/neon-0.30.2-msys2.patch

  #autoreconf -fi
}

build() {
  cd "${srcdir}"/${pkgbase}-${pkgver}
  ./configure --build=${CHOST} \
    --prefix=/usr \
    --with-expat \
    --enable-shared \
    --disable-static \
    --with-ssl=openssl \
    --with-ca-bundle=/usr/ssl/certs/ca-bundle.crt
  make

  make DESTDIR="${srcdir}/dest" install
}

package_libneon() {
  groups=('libraries')

  mkdir -p ${pkgdir}/usr/bin
  cp -f ${srcdir}/dest/usr/bin/*.dll ${pkgdir}/usr/bin/
  cp -rf ${srcdir}/dest/usr/share ${pkgdir}/usr/
}

package_libneon-devel() {
  pkgdesc="Libneon headers and libraries"
  groups=('development')
  options=('staticlibs')
  depends=("libneon=${pkgver}" 'libexpat-devel' 'openssl-devel')

  mkdir -p ${pkgdir}/usr/bin
  cp -f ${srcdir}/dest/usr/bin/*-config ${pkgdir}/usr/bin/
  cp -rf ${srcdir}/dest/usr/include ${pkgdir}/usr/
  cp -rf ${srcdir}/dest/usr/lib ${pkgdir}/usr/
}
